package com.Jano.dao.Impl;

import com.Jano.dao.UserDao;
import com.Jano.entity.User;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.util.Objects;

/**
 * description: UserDaoImpl <br>
 * date: 2022/6/6 10:54 AM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
public class UserDaoImpl extends AbstractDaoImpl implements UserDao {
    @Override
    public User login(String userName, String passWord) {
        return queryForObject("select id userId,username userName,pwd passWord from t_user", User.class);
    }

    @Override
    public Boolean isExist(String userName) {
        return !Objects.isNull(queryForObject("select username from t_user where username=?", User.class, new Object[]{userName}));
    }

    @Override
    public void register(String userName, String passWord) {
        update("insert into t_user (username,pwd) values(?,?)",new Object[]{userName, passWord});
    }

    @Test
    public void test() {
        //register("Jano","123");
        //System.out.println(login("Jano","123"));
        //System.out.println(isExist("Jano"));
    }
}
